﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyStep.Business.Interfaces;
using EasyStep.Business;
using EasyStep.Data;
using EasyStep.Attributes;

using EasyStep.Common;


namespace EasyStep.Business.Managers
{
    public class TestActionManager : ITestActionManager
    {
        public IEnumerable<TestAction> GetAll()
        {
            return TypeFinder.GetAllAction();
        }

        public TestAction Get(Guid actionId)
        {
            return TypeFinder.GetAction(actionId);            
        }        
        public TestAction GetParent(Guid actionId)
        {
            var action = Get(actionId);
            if (action == null) return null;
            return GetParent(action);
        }

        public TestAction GetParent(TestAction action)
        {
            return Get(action.ParentId);
        }

        public IEnumerable<TestAction> GetChildren(Guid parentId)
        {
            return TypeFinder.GetChildrenActions(parentId);
        }

       
        
        public TestAction GetByName(string uniqActionName)
        {
            return GetAll().Where(a => a.Name.Equals(uniqActionName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
        }
    }
}